package com.atguigu.staservice.controller;


import com.atguigu.commonutils.Response;
import com.atguigu.staservice.service.StatisticsDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author zhaolie
 * @since 2021-01-04
 */
@RestController
@RequestMapping("/staservice/sta")
@Api(description = "统计后台")
public class StatisticsDailyController {

    @Resource
    private StatisticsDailyService staService;

    @ApiOperation("统计莫一天的注册人数,生成统计数据")
    @PostMapping("registerCount/{day}")
    public Response registerCount(@PathVariable("day") String day) {
        staService.registerCount(day);
        return Response.SUCCESS();
    }

    @ApiOperation("图标显示,返回两部分数据,日期json数据和数量json数据")
    @GetMapping("showData/{type}/{begin}/{end}")
    public Response showData(@PathVariable("type") String type,
                             @PathVariable("begin") String begin,
                             @PathVariable("end") String end) {
        Map<String, Object> map = staService.getShowData(type, begin, end);
        return Response.SUCCESS().data(map);
    }
}

